
/*
* 删除车辆
* */
var removeCarDevice={
    /*android设备*/
    androidLoad:function(){
        var urls=baseAll.GetRequest(window.location.href);
        var token=AnroidWebActivity.getToken();
        var regiId=urls.regiId;
        document.querySelector('p.safe_city').innerHTML=urls.plateNo;//显示解除的车牌号
        removeCarDevice.relieveFunc(token,regiId);
    },
    /*ios设备*/
    iosLoad:function(){
        baseAll.runWebViewJavascriptBridgeArr(function(data,responseCallback){
            var objData = {};
            WebViewJavascriptBridge.callHandler("getToken", null, function (response) {
                objData.token = response; //IOS的token
            });
            WebViewJavascriptBridge.callHandler("getCar", null, function (response) {
                objData.carLicense = response;//IOS的account
                var plateNo=objData.carLicense.plateNo;//显示解除的车牌号
                var regiId=objData.carLicense.regiId;//regiId
                document.querySelector('p.safe_city').innerHTML=plateNo;
                removeCarDevice.relieveFunc(objData.token,regiId);
            });
        });
    },
    relieveFunc:function(token,regiId){
        AlterMobilePhone.init({
            required_register:true,
            formInput:".formInput",
            mobileText:"#mobile",//获取手机文本框
            getCodeBtn:"#get_code",//获取验证码按钮
            codeText:"#codes",//短信验证码
            nextBtn:"#relieveBtn",
            smsTPL:oPublic.DEL_BIKE,//短信模板编码
            model:{ //模态框
                modal:"#relieveCars",
                sureBtn:".sureBtn",
                cancelBtn:".closed_btn",
                codeImg:"#codeImg",//验证码图片
                imgTextBox:"#random_code"//图片随机验证码
            },
            //提交按钮判断显示
            statusSubBtn:function(formInput,mobileText,codeText,subBtn){
                $(formInput).keyup(function(){
                    var telephone=$(mobileText).val();
                    var shortCodes=$(codeText).val();
                    if(telephone.length==11&&shortCodes.length==4){
                        $(subBtn).attr("disabled",false).addClass("active_status");
                    }else{
                        $(subBtn).attr("disabled",true).removeClass("active_status");
                    }
                });
            },//进入下一步
            nextOperate:function(formInput,subBtn){
                var self=this;
                $(subBtn).on("click",function(){
                    var flag=true;
                    $(formInput).each(function(){
                        var regStr=$(this).attr("data-reg");
                        var errorMsg=$(this).attr("data-error");
                        var reg=new RegExp(regStr);
                        var oValue=$(this).val();
                        if(reg&&!reg.test(oValue)){
                            oPublic.errorText($(this),errorMsg,"warn","dl");
                            flag=false;
                            return;
                        }
                    });
                    //解除绑定--------------------------------------
                    if(flag){
                        baseAll.addLoading();
                        $.ajax({
                            type:"get",
                            url:oPublic.basePath()+"/s/bike/owner/registation/unbind",
                            dataType:"json",
                            crossDomain:true,
                            timeout:baseAll.timeout,
                            data:{
                                regiId:regiId,
                                mobile:$(self.mobileText).val(),
                                validateCode:$(self.codeText).val(),
                                token:token
                            },
                            success:function(data){
                                if(data.opStatus==0){
                                    baseAll.pubilcModal("解绑成功","确定",function(){
                                        baseAll.returnHandle();
                                    });
                                    baseAll.closeLoading();
                                }else{
                                    baseAll.pubilcModal(data.msgDesc);
                                    baseAll.closeLoading();
                                }
                            },
                            error:function(){
                                baseAll.pubilcModal('网络连接失败....');
                                baseAll.closeLoading();
                            }
                        })
                    }

                });
            }
        });
    }
}